using System.Collections.Generic;
using UnityEngine;

namespace Gj
{
    public static class BuffTools
    {
        private static readonly Dictionary<string, string> map;

        static BuffTools()
        {
            var settings = LoadSettings();
            map = new Dictionary<string, string>();
            for (var i = 0; i < settings.buffItems.Length; i++)
                map.Add(settings.buffItems[i].key, settings.buffItems[i].type);
        }

        private static BuffSettings LoadSettings()
        {
            var loadedSettings = (BuffSettings)Resources.Load("BuffSettings", typeof(BuffSettings));
            if (loadedSettings == null)
            {
                loadedSettings = ScriptableObject.CreateInstance<BuffSettings>();
                Debug.LogError("ReplaceSettings is not exist (Resources)");
            }

            return loadedSettings;
        }

        public static string Get(string key)
        {
            if (map.ContainsKey(key)) return map[key];
            return "";
        }
    }
}